package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @Author whx
 * @Date 2024/12/7 10:49
 */
@RestController
@RequestMapping("/admin/questions")
@Api(tags = "管理端问题相关接口")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {

    public final IInteractionQuestionService interactionQuestionService;

    @GetMapping("/page")
    @ApiOperation("管理端分页查询问题")
    public PageDTO<QuestionAdminVO> pageQuestionsForAdmin(QuestionAdminPageQuery questionAdminPageQuery){
        return interactionQuestionService.pageQuestionsForAdmin(questionAdminPageQuery);
    }

    @PutMapping("/{id}/hidden/{hidden}")
    @ApiOperation("hide or not")
    public void isHidden(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden){
        interactionQuestionService.isHidden(id, hidden);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询问题详情")
    public QuestionAdminVO getQuestionForAdmin(@PathVariable("id") Long id){
        return interactionQuestionService.getQuestionForAdmin(id);
    }

}
